// eslint-disable-next-line no-unused-vars
import React, { PureComponent } from 'react'
import { connect } from 'react-redux'
import PropTypes from 'prop-types'

class AuthorizedComponent extends PureComponent {
  static propTypes = {
    authList: PropTypes.array,
    auth: PropTypes.string,
    children: PropTypes.any
  }
  constructor (props) {
    super(props)
    this.state = {}
  }

  render () {
    const { children, authList, auth } = this.props
    if (authList && authList.includes(auth)) {
      return (
        <>
          { children }
        </>
      )
    }
    return null
  }
}

const mapState = state => ({
  authList: state.common.auth
})
const mapDispatch = dispatch => ({
})

export default connect(
  mapState,
  mapDispatch
)(AuthorizedComponent)
